package pri.hillchen.std.design.pattern.single;

import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by hillchen on 2018/3/8.
 */
public class LazyRegist {
    private static String HAS_KEY = "has";
    private static LazyRegist lazyRegist;
    private static ConcurrentHashMap<String,LazyRegist> map = new ConcurrentHashMap<>();
    private LazyRegist (){}
    public static LazyRegist getInstance(){
        if(map.containsKey(HAS_KEY)){
            return map.get(HAS_KEY);
        }else{
            map.putIfAbsent(HAS_KEY,new LazyRegist());
            return map.get(HAS_KEY);
        }
    }
}
